package popcorn.ticket.listener;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import popcorn.ticket.job.timerJobTest;
import popcorn.ticket.job.timerJobTest2;

public class TomcatListener implements ServletContextListener{

	private Timer timer = null;
	
	private Timer timer2 = null;
	
	@Override
	public void contextDestroyed(ServletContextEvent sce) {

	}
	
	@Override
	public void contextInitialized(ServletContextEvent sce) {
		// 创建守护线程
		
		timer = new Timer(true);  
		
		timer2 = new Timer(true);

		timerJobTest tjb = new timerJobTest();
		timerJobTest2 tjb2 = new timerJobTest2();
		
		timer.schedule(tjb, 10*1000, 60*1000); //是容器启动10秒以后，每60秒执行一次
		timer2.schedule(tjb2, 10*1000, 60*1000);

	}
}
